package com.example.java_chatroom_redis_rabbitmq.mapper;

import com.example.java_chatroom_redis_rabbitmq.model.Friend;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface FriendMapper {
    @Select("select friendId from friend where userId=#{userId}")
    List<Integer> getFriendIdByUserId(@Param("userId") Integer userId);

    @Insert("insert into friend(userId,friendId) values(#{userId},#{friendId}),(#{friendId},#{userId})")
    Integer addFriend(@Param("userId") Integer userId,@Param("friendId") Integer friendId);

    @Select("select id from friend where userId=#{userId} and friendId=#{friendId}")
    Integer checkIsFriend(@Param("userId") Integer userId,@Param("friendId") Integer friendId);
}
